From: | Javier de las Rivas |
Date: | 15 May 2001 at 19:48:11 |
Subject: | [D5] CDDAscript.dopus 1st version |
Well think i finished, don't know if it's bullet proof, but here it is, if
you want feel free to change or suggest whatever.
1 question:
Is there another way of wating for selecting a track instead of?
DO UNTIL reproducir.count=1
LISTER QUERY handle SELFILES STEM reproducir.
END
I know is a bit ugly programming, but i'm new to ARexx programing.
another question this for dave clark:
can you explain what this is, i can figure it waits for an event
(doubleclick,...) but could you explain it these lines if you don't mind,
if it's OT please reply to my addres.
if waitpkt(myhandler) then do
packet = getpkt(myhandler)
if packet ~= '00000000'x then do
event = getarg(packet,0)
fname = getarg(packet,2)
arg3 = getarg(packet,3)
select
when event = 'inactive' then leave.....
---------------------------------
/*
$VER: CDDAscript.dopus5 1.0 (15.05.01) Javier de las Rivas <javierdlr@jazzfree.com>
Needs:
DOpus5 - GPSoftware
CDDA - AMINET
ShowTOC - AMINET
Break - AmigaOS
Status - AmigaOS
Wait - AmigaOS
rexxsupport.library - AmigaOS
CDDA has to envvars:
cdda_device: defaults scsi.device
cdda_unit: defaults 2
Use SetEnv from CLI/Shell to change them to your needs.
Example: SetEnv cdda_device blizzppc.device
*/
signal on break_c
signal on error
OPTIONS RESULTS
OPTIONS FAILAT 11
/* Change them to fit your needs see CDDA/ShowTOC docs for more info */
CDDAcmd="DH2:MUSICA/cdda VOL=200 PLAN=a"
TOCcmd ="DH2:MUSICA/ShowTOC D=blizzppc.device U=2 CDIDDIR=DH2:MUSICA"
lf='0a'x
ADDRESS "DOPUS.1"
if ~SHOW(libraries,"rexxsupport.library") THEN ADDLIB("rexxsupport.library",0,-30,0)
/* Miramos si ya tiene una lista y avisamos */
IF OPEN('listfile', 'T:CDDAlista', 'R') THEN DO
DOPUS REQUEST '"CDDA lister already open." OK'
CLOSE('listfile')
call SALIR()
END
ELSE DO
/* Sacamos una lista con las canciones del CD */
ADDRESS COMMAND TOCcmd' HEADFMT="%a*n%T" FMT="%y-%d-%n-%t" NOTAIL >T:CDDAlista'
OPEN('listfile', 'T:CDDAlista', 'R')
grupo=READLN('listfile')
IF LEFT(grupo,10)='Error acce' THEN call FALTACD()
titulo=READLN('listfile')
LISTER NEW
handle=RESULT
IF grupo='' THEN grupo='CDDA'
LISTER SET handle LABEL grupo
LISTER SET handle TITLE 'CDDAscript.dopus5'
LISTER SET handle HEADER titulo
LISTER SET handle FIELD off
LISTER SET handle FIELD 0 "Song" 4 "Duration"
LISTER SET handle FIELD on
LISTER SET handle DISPLAY name comment
linea=READLN('listfile')
DO UNTIL EOF('listfile')
PARSE VAR linea tipo'-'tiempo'-'numero'-'cancion
IF cancion='' THEN cancion='<unknown>'
entrada.name=numero'-'cancion
entrada.comment=tiempo
IF tipo='Audio' THEN LISTER ADDSTEM handle entrada
linea=READLN('listfile')
END
CLOSE('listfile')
/* Comprobamos que el CD no es de solo datos */
LISTER QUERY handle NUMFILES
IF RESULT=0 THEN DO
DOPUS REQUEST '"CD inserted is only DataCD." OK'
call BREAK_C()
END
ESPERA:
/* Esperamos a que escoja una canci�n */
LISTER REFRESH handle FULL
LISTER QUERY handle SELFILES STEM reproducir.
DO UNTIL reproducir.count=1
LISTER QUERY handle SELFILES STEM reproducir.
END
elegida=reproducir.0
LISTER QUERY handle ENTRY elegida STEM entrada.
tiempo=entrada.comment
PARSE VAR tiempo mins':'segs';'dseg
segundos=(60*mins)+segs
LISTER SELECT handle '"'elegida'"' OFF
PARSE VAR elegida pista'-'nombre
/* Reproducimos la pista elegida */
ADDRESS COMMAND 'Run >T:CDDAproc 'CDDAcmd 'TRACK='pista
/* Obtenemos el n�mero de proceso de CDDA */
OPEN('procfile', 'T:CDDAproc', 'R')
process=READLN('procfile')
PARSE VAR process '[CLI 'proceso']'
CLOSE('procfile')
DELETE('T:CDDAproc')
/* Miramos si CDDA se ha ejecutado bien */
malcdda=1
ADDRESS COMMAND 'Wait 2 SEC'
ADDRESS COMMAND 'Status >NIL: 'proceso
malcdda=0
/* Si no hay problemas seguimos */
LISTER SET handle BUSY ON
LISTER SET handle NEWPROGRESS INFO ABORT
LISTER SET handle NEWPROGRESS TITLE "Playing track "pista'...'
IF cancion='<unknown>' THEN
LISTER SET handle NEWPROGRESS INFO '0:00'
ELSE LISTER SET handle NEWPROGRESS INFO nombre' 0:00'
/* Esperamos a que el usuario aborte o que acabe la canci�n */
cseg=0
cmin=0
contar=0
abortar=0
Time('R')
DO WHILE abortar=0 & contar<segundos
Delay(50)
contar=TRUNC(TIME('E'))
cseg=contar-(60*cmin)
IF cseg>59 THEN DO
cmin=cmin+1
cseg=0
END
zseg=cseg
IF LENGTH(cseg)<2 THEN zseg="0"cseg
IF cancion='<unknown>' THEN
LISTER SET handle NEWPROGRESS INFO cmin':'zseg
ELSE LISTER SET handle NEWPROGRESS INFO nombre' 'cmin':'zseg
LISTER QUERY handle ABORT
abortar=RESULT
IF abortar=1 THEN ADDRESS COMMAND 'Break >NIL: 'proceso
END
LISTER CLEAR handle ABORT
LISTER SET handle BUSY OFF
call ESPERA()
END
/* Falta CD */
FALTACD:
CLOSE('listfile')
DELETE('T:CDDAlista')
DOPUS REQUEST '"Insert an AudioCD." OK'
call SALIR()
/* Si encuentra alg�n error o Ctrl+C */
ERROR:
BREAK_C:
IF malcdda=1 THEN DOPUS REQUEST '"CDDA not configured." OK'
DELETE('T:CDDAlista')
LISTER QUERY handle BUSY
IF RESULT=1 THEN DO
ADDRESS COMMAND 'Break >NIL: 'proceso
LISTER SET handle BUSY OFF
END
LISTER CLOSE handle
SALIR:
EXIT 0
-------------------------------
THX